import { create } from '../asyncActionCreator';

export const TypeOption = {
	Practice: 0,
	Mission: 1,
	PK: 2
}

export const PRACTICE_URL = '/api/data/Practice';
export const MISSION_URL = '/api/data/Mission';
export const PK_URL = '/api/data/PK';

export const GET_PRACTICE_DATA_REQUEST = 'request practice data';
export const GET_PRACTICE_DATA_SUCCESS = 'request practice data success';
export const GET_PRACTICE_DATA_FAILURE = 'request practice data failure';

export const getPracticeDataRequest = (key) => ({
	type: GET_PRACTICE_DATA_REQUEST,
	payload: {
		key
	}
});

export const getPracticeDataSuccess = (key, data) => ({
	type: GET_PRACTICE_DATA_SUCCESS,
	payload: {
		key,
		data
	}
});

export const getPracticeDataFailure = (key, message) => ({
	type: GET_PRACTICE_DATA_FAILURE,
	payload: {
		key,
		message
	}
});

export const getPracticeData = (url, key, params) => (create(
	url,
	getPracticeDataRequest.bind(null, key),
	getPracticeDataSuccess.bind(null, key),
	getPracticeDataFailure.bind(null, key),
	params
));
